import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete
} from '@nestjs/common'
import { ContractService } from './contract.service'
import { CreateContractDto } from './dto/create-contract.dto'
import { UpdateContractDto } from './dto/update-contract.dto'
import { NoAuth } from 'src/role/decorators/no-auth.decorator'
import { FResponse } from 'src/utils/reponse'
@NoAuth()
@Controller('contract')
export class ContractController {
  constructor(private readonly contractService: ContractService) {}

  @Post()
  async create(@Body() createContractDto: CreateContractDto) {
    return FResponse.success(
      await this.contractService.create(createContractDto)
    )
  }

  @Get(':id')
  async findOne(@Param('id') id: string) {
    return FResponse.success(await this.contractService.findOne(+id))
  }

  @Get('staff/:id')
  async findOneByStaffId(@Param('id') id: string) {
    return FResponse.success(await this.contractService.findOneByStaffId(+id))
  }

  @Patch(':id')
  async update(
    @Param('id') id: string,
    @Body() updateContractDto: UpdateContractDto
  ) {
    return FResponse.success(
      await this.contractService.update(+id, updateContractDto)
    )
  }
}
